package org.lanqiao.ssm.web.auth.controller;

import java.util.List;

import javax.annotation.Resource;

import org.lanqiao.ssm.common.facede.BaseManagerFacedeI;
import org.lanqiao.ssm.common.facede.BaseQueryFacedeI;
import org.lanqiao.ssm.common.model.Json;
import org.lanqiao.ssm.common.web.controller.BaseController;
import org.lanqiao.ssm.facede.auth.facede.MenuManagerFacedeI;
import org.lanqiao.ssm.facede.auth.facede.MenuQueryFacedeI;
import org.lanqiao.ssm.facede.auth.model.Menu;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@SuppressWarnings("all")
@RestController
@RequestMapping("/menu")
public class MenuController extends BaseController<Menu, String>
		 {
	@Resource
	private MenuManagerFacedeI menuManagerFacede;
	@Resource
	private MenuQueryFacedeI menuQueryFacede;

	@Override
	public BaseManagerFacedeI<Menu, String> getManagerFacede() {
		return menuManagerFacede;
	}

	@Override
	public BaseQueryFacedeI<Menu, String> getQueryFacede() {
		return menuQueryFacede;
	}

	@RequestMapping(value = "/findAllTreeNode", method = RequestMethod.GET)
	public List<Menu> findAllTreeNode() {

		return menuQueryFacede.findAllTreeNode();
	}

	@RequestMapping(value = "/treegrid", method = RequestMethod.GET)
	public List<Menu> treegrid() {
		return menuQueryFacede.treegrid();
	}

	@RequestMapping(value = "/remove", method = RequestMethod.POST)
	public Json remove(String id) {
		return menuManagerFacede.remove(id) > 0 ? setSimpleSuccess(id)
				: setFailed();
	}

	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public Json add(Menu menu) {

		return menuManagerFacede.add(menu) > 0 ? setSimpleSuccess(menu)
				: setFailed();
	}

	@RequestMapping(value = "/edit", method = RequestMethod.POST)
	public Json edit(Menu menu) {

		return menuManagerFacede.edit(menu) > 0 ? setSimpleSuccess(menu)
				: setFailed();
	}

}
